#pragma once

#include <pthread.h>

//对互斥锁进行简单的包装
class Mutex
{
public:
    //构造函数
    Mutex(pthread_mutex_t *lock):lock_(lock)
    {}
    //加锁
    void Lock()
    {
        pthread_mutex_lock(lock_);
    }
    //解锁
    void Unlock()
    {
        pthread_mutex_unlock(lock_);
    }
    ~Mutex()
    {}
private:
    //定义一把锁
    pthread_mutex_t *lock_;
};


//封装一个
class LockGuard
{
public:
    LockGuard(pthread_mutex_t *lock):mutex_(lock)
    {
        mutex_.Lock();
    }
    ~LockGuard()
    {
        mutex_.Unlock();
    }
private:
    Mutex mutex_;
}; 